package com.mive.controller;

import com.mive.entity.User;
import com.mive.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Allen
 * @version 1.0.0
 * @createTime 2018-06-08 15:11
 * @description 用户信息
 */
@Controller
@RequestMapping("/user.do")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/findAll")
    public String findAll(Model model){
        List<User> list = userService.findAll();
        model.addAttribute( "users", list);
        return "user";
    }

    @RequestMapping(value = "/queryAll")
    @ResponseBody
    public List<User> queryAll(Model model){
        List<User> list = userService.findAll();
        return list;
    }
}
